package com.bootdo.clouddo.service.juejin.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bootdo.clouddo.dao.juejin.CategoryDao;
import com.bootdo.clouddo.domain.juejin.CategoryDO;
import com.bootdo.clouddo.service.juejin.ICategoryService;

@Service
public class CategoryServiceImpl implements ICategoryService {
	
	@Autowired
	private CategoryDao categoryDao;

	@Override
	public int save(CategoryDO category) {
		return categoryDao.insertSelective(category);
	}

	@Override
	public CategoryDO get(String id) {
		return categoryDao.selectByPrimaryKey(id);
	}

	@Override
	public List<CategoryDO> findAll() {
		List<CategoryDO> list = categoryDao.selectAll();
		list.sort((c1, c2) -> c1.getPx() - c2.getPx());
		return list;
	}

}
